package org.dzms.dao;

import java.util.List;

import org.dzms.commons.DataHandler;
import org.dzms.commons.PageHandler;
import org.dzms.entity.Userinfos;

public class PersonLevelDAO {
	/*
	 * 用户等级的增删改查方法
	 */
	
	//查询所有的信息
	public List<Userinfos> findAll(){
		String sql = "select * from userinfos";
		return DataHandler.query(sql, null, Userinfos.class);
	}
	
	//保存用户所有信息
	public void savaUsers(Userinfos us){
		String sql ="insert into userinfos(username,usersex,telephone,password,userpic,integral,introducemyself,postcode,alwaddress,actaddress) "
				+ "values(?,?,?,?,?,？,?,?,?,?)";
		DataHandler.update(sql, new Object[]{us.getUsername(),us.getUsersex(),us.getTelephone(),us.getPassword(),us.getUserpic(),us.getIntegral(),us.getIntroducemyself(),us.getPostcode(),us.getAlwaddress(),us.getActaddress()});
	}
	
	//删除用户信息(调用的是单查的方法)
	public void deleteUsers(int userid){
		String sql = "delete from userinfos where userid=?";
		DataHandler.update(sql, new Object[]{userid});
	}
	
	//更新用户信息-更新积分值
	public int updateIntegral(int userid){
		String sql = "update userinfos set intergral=intergral+10 where userid=?";
		return DataHandler.update(sql, new Object[]{userid});
	}
	
	//更新用户头像
	public void updateUserpic(Userinfos us){
		String sql = "update userinfos set userpic=? where userid=?";
		DataHandler.update(sql, new Object[]{us.getUserpic(),us.getUserid()});
	}
	
	//分页
	public <E>List<E> findCurrentPageData(PageHandler handler){
		return null;
	}
	
	public int findCountPage(PageHandler handler){
		return 0;
	}
}